package com.zpark.humpro.mapper;

import com.zpark.humpro.entity.Human;
import com.zpark.humpro.utils.JdbcUtil;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

/**
 * 与数据库连接，查询的数据保存到List表单中
 */
public class HumanInformationMapperImpl implements HumanInformationMapper {


    @Override
    public List<Human> selectAll() {

        Connection conn = JdbcUtil.getConnection();
        String sql = "select * from person_tb";
        try {
            PreparedStatement prepared = conn.prepareStatement(sql);
            //将查询的信息保存到结果集
            ResultSet resultSet = prepared.executeQuery();
            List<Human> humanList = new ArrayList<>();

            while (resultSet.next()){
                Human human = new Human();
                human.setName(resultSet.getString("name"));

            }


        } catch (SQLException e) {
            e.printStackTrace();
        }

        return null;
    }
}
